def main():
    s1 = raw_input()
    s2 = raw_input()
    if len(s1)!=len(s2) :
        print 'No'
        return
    set1 = {}
    set2 = {}
    for i in xrange(len(s1)):
        set1[s1[i]] = set1.setdefault(s1[i],0)+1
        set2[s2[i]] = set2.setdefault(s2[i],0)+1
    if len(set1)!=len(set2) :
        print 'No'
        return
    if set1!=set2 :
        print 'No0'
        return
    for key in set1 :
        if set1[key] != set2.setdefault(key,0) :
            print 'No'
            return
    # for key in set2 :
    #     if set2[key] != set1.setdefault(key,0) :
    #         print 'No'
    #         return
    print 'Yes'


if __name__=='__main__':
    main()